import request from '@/utils/request'
import type { User, UserQuery } from './type'
//项目用户相关的请求地址
const baseUrl = '/user'

//分页
export const reqUserPage = (
  pageNum: number,
  pageSize: number,
  queryParams: UserQuery,
) =>
  request.post<any, TableResponse<Array<User>>>(`${baseUrl}/page`, {
    pageSize,
    pageNum,
    ...queryParams,
  })
//修改用户状态
export const reqChangeStatus = (userId: string, status: string) =>
  request.get<any, ResponseData>(`${baseUrl}/changeStatus`, {
    params: {
      userId,
      status,
    },
  })

//删除用户
export const reqDeleteUser = (ids: string[] | string) =>
  request.delete<any, ResponseData>(`${baseUrl}/${ids}`)

//重置密码
export const reqResetUserPwd = (userId: string, password: string) =>
  request.put<any, ResponseData>(`${baseUrl}/resetPassword`, {
    userId,
    password,
  })

//新增/修改用户
export const reqAddUser = (data: User) => request.post<any, void>(baseUrl, data)
export const reqUpdateUser = (data: User) =>
  request.put<any, ResponseData>(baseUrl, data)
